/*
 * "Copyright (c) 2012 Universitat Pompeu Fabra.
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 *
 * IN NO EVENT SHALL UNIVERSITAT POMPEU FABRA BE LIABLE TO ANY PARTY 
 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING 
 * OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF POMPEU FABRA
 * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * UNIVERSITAT POMPEU FABRA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND UNIVERSITAT POMPEU FABRA HAS NO OBLIGATION TO 
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 */

#ifndef __HbcpNETWORKPACKETS_H__
#define __HbcpNETWORKPACKETS_H__

#include "HbcpParameters.h"

enum {
	HBTP_TYPE = 0x22,
	ROUTING_TYPE = 1,
	DATA_TYPE = 2,
	CONFIG_TYPE = 3
};

enum {
	DATA_QUEUE_LEN = 20,
};

typedef nx_struct generalFrame {
	nx_uint8_t networkID;
	nx_uint16_t source;
	nx_uint8_t type;
	nx_uint8_t length;
} generalFrame_t;

typedef nx_struct routingPacket {
	generalFrame_t generalFrame;
	nx_uint8_t hop;
	nx_uint16_t session;
	nx_uint8_t battery;
	nx_uint16_t coordinationTime;

	nx_uint8_t maxHops;
	nx_uint16_t groupSlotTime;
	nx_uint16_t collectionTime;

	nx_int8_t thresholdRssi;
	nx_int8_t dangerRssi;
	nx_uint8_t transmissionPower;

} routingPacket_t;

typedef nx_struct payloadFrame {
	nx_uint8_t size;
	nx_uint8_t packet[100];
} payloadFrame_t;

typedef nx_struct dataPacket {
	generalFrame_t generalFrame;
	nx_uint8_t hop;
	nx_uint8_t battery;
	nx_uint8_t payloadsNum;
	nx_uint8_t payloadsSize;
	nx_uint8_t payload[DATA_LENGTH];
} dataPacket_t;

#endif
